<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

require_once 'class.upload.php';
require_once 'resize-class.php';


$uploader = new Uploader();
$uploader->setDir('upload/image/');
$uploader->setExtensions(array('jpg', 'jpeg', 'png', 'gif'));  //allowed extensions list//
$uploader->setMaxSize(5);  //set max file size to be allowed in MB//
$uploader->setSequence('Mood');
$uploader->setSameFileName(FALSE);

if ($uploader->uploadFile('picture')) {   //txtFile is the filebrowse element name //
	echo $image = $uploader->getUploadName();  //get uploaded file name, renames on upload//
	// *** 1) Initialise / load image
	$resizeObj = new resize('upload/image/'.$uploader->getUploadName());
	// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
	$resizeObj -> resizeImage(200, 200, 'crop');
	// *** 3) Save image
	$resizeObj -> saveImage('upload/image/'.'resized'.$uploader->getUploadName(), 100);
} else {//upload failed
	echo $uploader->getMessage();  //get upload error message
}
?>